/**
 * If there are no bugs, it was created by Chen FengYao on 2018/4/2;
 * Otherwise, I don't know who created it either
 */

public class Test05 {
    public static void main(String[] args) {
        int[] arr = {1, 3, 5, 2, 4};
        int ab = 3;
        int[] a = new int[ab];

        // 从 小 到 大  排序
        // 冒泡排序
        // 核心思想: 保证,数组中 右边的数 >= 左边的数
        //          否则 就交换这两个数
        /*
        => 1 3 5 2 4
        =>
         */


        for (int j = 0; j < arr.length; j++) {
            //这个循环负责 循环5次
            for (int i = 0; i < arr.length - 1; i++) {
                // 每一次循环
                //就保证 右边的数 比 左边大
                if (arr[i + 1] < arr[i]) {
                    int temp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = temp;
                }
            }
        }


        //输出整个数组 看结果
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }

    }
}
